# -*- coding: utf-8 -*-

def to_utf8(s):
    return unicode(s).encode('utf-8')

class Document(object):
    """
    Abstraction of document.
    """
    def __init__(self, text = None, attrs = None, keywords = None, hidden = None):
        self.text = text or ''
        self.hidden = hidden or ''
        self.attrs = attrs or {}
        self.keywords = keywords or {}

    def dump_draft(self):
        buf = []
        buf.append("\n".join(["@%s=%s" % (to_utf8(k), to_utf8(v)) for k, v in self.attrs.items()]))
        buf.append("")
        buf.append(to_utf8(self.text))
        return "\n".join(buf)


